<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>::Happy - DTAC Prepaid Phone::</title>
<link href="${RESOURCE}/css/global.css" rel="stylesheet" type="text/css">
<link href="${RESOURCE}/css/global-en.css" rel="stylesheet" type="text/css">
<link href="${RESOURCE}/css/customize.css" rel="stylesheet" type="text/css">
<script src="${RESOURCE}/eng/include/AC_RunActiveContent.js" type="text/javascript"></script>

<script language=JavaScript>

function printWindow(){

browserVersion = parseInt(navigator.appVersion)

if (browserVersion >= 4) window.print()

}



function include(xUrl,xId) {

  var xmlhttp = false;

  /*@cc_on @*/

  /*@if (@_jscript_version >= 5)



  // JScript gives us Conditional compilation, we can cope with old IE versions.

  // and security blocked creation of the objects.

  try {

    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

   } catch (e) {

      try {

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (E) {

        xmlhttp = false;

      }

   }



  /*@end @*/

  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {

    xmlhttp = new XMLHttpRequest();

  }



  xmlhttp.open("GET", xUrl,true);

  xmlhttp.onreadystatechange=function() {

          if (xmlhttp.readyState==4) {

                document.getElementById(xId).innerHTML = xmlhttp.responseText;

          }

  }

  xmlhttp.send(null)

}





function doSubmit() {

	//var phone = document.form.lisPhoneNo.value;

	var f = document.forms[0]; 



	if( !isCorrectMobileFormat(f.subrNumb) ) {


			f.subrNumb.value="";
			f.subrNumb.focus();



			return;

	}



	var subrNumb = trim(f.subrNumb.value);

	var subrNumb1 = "";

	var subrNumb2 = "";

	var subrNumb3 = "";



	if(f.subrNumb.value.length == 10){

		subrNumb1=subrNumb.substring(0,2);

		subrNumb2=subrNumb.substring(2,6);

		subrNumb3=subrNumb.substring(6);



		f.m1.value=subrNumb1;

		f.m2.value=subrNumb2;

		f.m3.value=subrNumb3;



	}else{

		subrNumb1=subrNumb.substring(0,1);

		subrNumb2=subrNumb.substring(1,5);

		subrNumb3=subrNumb.substring(5);



		f.m1.value=subrNumb1;

		f.m2.value=subrNumb2;

		f.m3.value=subrNumb3;

	}



	/*

	if( !isCorrectMobileFormat1(f.m1) ) {

			f.m1.focus();

			return;

	}



	if( !isCorrectMobileFormat4(f.m2) ) {

			f.m2.focus();

			return;

	}



	if( !isCorrectMobileFormat4(f.m3) ) {

			f.m3.focus();

			return;

	}			

	*/



	if( !isCorrectSerialFormat() ) {
		document.form.txtSerialNo.value="";
		document.form.txtSerialNo.focus();

   		return;

	}


	if( !isCorrectIdFormat() ) {
		document.form.txtIdNo.value="";
		document.form.txtIdNo.focus();

   		return;

	}	



	ok();

	//window.form.submit();

}



function ok(){

  var toSubNumb1 = document.form.m1.value;

  var toSubNumb2 = document.form.m2.value;

  var toSubNumb3 = document.form.m3.value;

	var toSubNumb =  toSubNumb1+"-"+toSubNumb2+"-"+toSubNumb3;

	var msg = "<strong> Refills using your refill card:</strong> Click accept to refill money to mobile number  <span class=\"textnormalred\">"+toSubNumb+"</span ><br><br>";

	//window.open("/bp3/bin/confirm?msg= "+msg,"refillvoucher","width=250, height=100");

	

	var w = 375;

	var h = 150;

	var l = (screen.width - w) / 2; 

	var t = (screen.height - h ) / 2; 

	//window.open("/bp3/bin/confirm?msg= "+msg,"refillvoucher","width=" + w + ", height=" + h + ", top=" + t + ", left=" + l);

	document.forms[0].hdConfirmMsg.value = msg;

	window.open("/bp3/bin/confirm?lang=E&mode=N", "refillvoucher","width=" + w + ", height=" + h + ", top=" + t + ", left=" + l);



/*    if (confirm("บริการใจดี..ให้ยืม: กดยืนยันเพื่อรับสิทธิ์ใช้บริการโดยระบบจะเติมเงิน 30 บาทให้กับหมายเลขของคุณ โดยไม่เพิ่มวันใช้งาน")) {

      document.form.func.value = "save";

      window.form.submit(); 

    }*/

}



function next1() {

	var f = document.forms[0];

	if(f.m1.value.length == 2) {

		f.m2.focus();

	}

}



function next2() {

	var f = document.forms[0];

	if(f.m2.value.length == 4) {

		f.m3.focus();

	}

}


function  HppyCrdtRfllWeb(){

  window.open("https://services.dtac.co.th/HppyCrdtRfllWeb/bp3/bin/HappyCrdtRfllSwitchLangOff.html");

}

function gotoIndex(){

  window.location = "/bp3/bin/Dspc/DpromptWelcome";  

}



function gotoIndex1(){

   JavaScript:location.href='/bp3/bin/DpromptIndex';

}



function CheckButton(){

  var f = document.forms[0]; 



	if ( document.form.radiobutton[0].checked == true ){

		f.p1.value="";			

		f.p1.blur();

		f.p2.value="";			

		f.p2.blur();

		f.p3.value="";			

		f.p3.blur();			

		f.m1.focus();			



	}else if ( document.form.radiobutton[1].checked == true ){		

		f.m1.value="";			

		f.m1.blur();

		f.m2.value="";			

		f.m2.blur();

		f.m3.value="";			

		f.m3.blur();			

		f.p1.focus();			

	}

}



function isCorrectMobileFormat(obj){	

	//var f = document.forms[0];    

	var serialNo = /^[0-9]{10}$/;	

	var errorMessage = "";	



	if ( !serialNo.test(obj.value) ) errorMessage += "Invalid mobile phone number.";				

		if ( errorMessage.length > 0 ) {

			alert("Format data incorrect:\n\n" + errorMessage);

	

			return false;

		}		



	return true;

}



function isCorrectMobileFormat1(obj){	

	//var f = document.forms[0];    

	var serialNo = /^[0-9]{2}$/;	

	var errorMessage = "";	



	if ( !serialNo.test(obj.value) ) errorMessage += "Invalid mobile phone number.";				

	

	if ( errorMessage.length > 0 ) {

		alert("Format data incorrect:\n\n" + errorMessage);

		

		return false;

	}		



	return true;

}



function isCorrectMobileFormat4(obj){	

	//var f = document.forms[0];    

	var serialNo = /^[0-9]{4}$/;	

	var errorMessage = "";	



	if ( !serialNo.test(obj.value) ) errorMessage += "Invalid mobile phone number.";				



	if ( errorMessage.length > 0 ) {

		alert("Format data incorrect:\n\n" + errorMessage);



		return false;

	}		



	return true;

}



function isCorrectSerialFormat(){	

	var f = document.forms[0].txtSerialNo;	 		

	var errorMessage = "Please fill card number as shown on your refill card.\n";



	if ( !isInt(f) || (f.value.length < 9) ) {		

		alert("Format data incorrect:\n\n" + errorMessage);



		return false;

	}



	return true;	

}



function isInt(textObj){

  var newValue = textObj.value;

  newValue = trim(newValue);

  var newLength = newValue.length;



  for(var i = 0;i != newLength; i++)  {

     aChar = newValue.substring(i,i+1);

     

     if(aChar < "0" || aChar > "9") {return false;}

  }



  return true;     

}



function trim(s) {

  while (s.substring(0,1) == ' ') {

    s = s.substring(1,s.length);

  }



  while (s.substring(s.length-1,s.length) == ' ') {

    s = s.substring(0,s.length-1);

  }



  return s;

}



function isCorrectIdFormat(){	

	var f = document.forms[0];    

	var IdNo = /^[0-9]{6}$/;	

	var errorMessage = "";

	var IdNovalue = f.txtIdNo.value;



	IdNovalue = trim(IdNovalue);



	if ( !IdNo.test(IdNovalue) ) errorMessage += "Please fill Refill card code as shown on your refill card.\n";				



	if ( errorMessage.length > 0 ) {

		alert("Format data incorrect:\n\n" + errorMessage);



		return false;

	}		



	return true;

}



function gotoWelcome(){

	window.location = "/bp3/bin/Dspc/DpromptWelcome";

}

</script> 

</head>
<body>
<div id="header">
    <%@include file="../head.jsp" %>
</div>

<div id="container">
	<div id="pathway"><a href="/bp3/bin/DpromptIndex" class="link2">Web service</a> > <a href="/bp3/bin/Dspc/DpromptWelcome"  class="link2">Profile and Service</a> > Refill Using Call-Credit Refill Card </div>
	<div id="main">
    	<%@ include file="../menu.jsp" %>
    	<div id="content">
        	<div class="content-middle">
                
                <!--เนื้อหาเริ่มที่นี่-->
                <h3><img src="${RESOURCE}/eng/images/14_webservice_head01.gif"></h3>
               	<table width="100%" cellpadding="2" cellspacing="2" height="500">
                  	<tr>
                    	<td valign="top">
						
						<form name="form" method="post" action="DpromptRefillVoucher"  >

                          <input type="hidden" name="hdConfirmMsg" value="">

                          <table width="650" border="0" cellspacing="0" cellpadding="0">

                            <!--SVLT.VAR:CONF_TOP-->

                            <tr>

                              <td><br>

                                  <!--SVLT.LOOP:ERROR_BOX-->

                                  <table  border="0" cellspacing="0" cellpadding="2" width="100%">

                                    <tr>

                                      <td align="center" class="textnormalred_bold">The system cannot complete your transaction because</td>

                                    </tr>

                                    <tr>

                                      <td align="center"  class="textnormalred"><!--SVLT.VAR:ERROR_MSG--></td>

                                    </tr>

                                  </table>

                                <!--SVLT.END:ERROR_BOX-->

                                  <br>

                                  <table width="100%" border="0" cellspacing="3" cellpadding="0">

                                    <tr>

                                      <td width="2%"><img src="${RESOURCE}/eng/images/14_webservice_bullet01.gif" width="9" height="9"></td>

                                      <td width="98%" class="textnormal_bold"><img src="${RESOURCE}/eng/images/14_webservice_subtitle03.gif" width="350" height="22"></td>

                                    </tr>

                                    <tr>

                                      <td>&nbsp;</td>

                                      <td class="textnormal">Have a call-credit refill card? Instantly refill your call-credit now! You can even make refill to another number of your choice with this service! </td>

                                    </tr>

                                </table></td>

                            </tr>

                            <tr>

                              <td height="15" align="center"><br>

                                  <br>

                                  <br></td>

                            </tr>

                            <tr>

                              <td height="15" align="center" >

                                

                                <table width="80%" border="0" align="center" cellpadding="2" cellspacing="2">

													        <tr> 

													          <td width="45%" align="right" class="textnormal_bold">Refill to Happy Mobile Number:</td>

													          <td><input name="subrNumb" type="text" class="txt_search_c04" maxlength="10" size="30" autocomplete="off"></td>

                                    <input type="hidden" name="m1" size="2" maxlength="2" value="<!--SVLT.VAR:m1-->" class="textnormal"  >

                                    <input type="hidden" name="m2" size="4" maxlength="4" value="<!--SVLT.VAR:m2-->" class="textnormal" >

                                    <input type="hidden" name="m3" size="4" maxlength="4" value="<!--SVLT.VAR:m3-->" class="textnormal" >

													        </tr>

													        <tr> 

													          <td align="right" class="head">&nbsp;</td>

													          <td><font color="#FF0000" class="textredsmall">Mobile phone number 10 digits (08xxxxxxxx)</font></td>

													        </tr>

													        <tr> 

													          <td align="right" class="textnormal_bold">Serial No.:</td>

													          <td><input name="txtSerialNo" type="text" class="txt_search_c04" maxlength="9" size="30" autocomplete="off"></td>

													        </tr>

													        <tr> 

													          <td align="right" class="head">&nbsp;</td>

													          <td><font color="#FF0000" class="textredsmall">(9 digits or more) as shown on your refill card</font></td>

													        </tr>

													        <tr> 

													          <td align="right" class="textnormal_bold">ID No.:</td>

													          <td><input name="txtIdNo" type="text" class="txt_search_c04" maxlength="6" size="30" autocomplete="off"></td>

													        </tr>

													        <tr> 

													          <td align="right" class="head">&nbsp;</td>

													          <td><font color="#FF0000" class="textredsmall">(6 digits or more) as shown on your refill card</font></td>

													        </tr>

													      </table>

                                 

                                <input name="func" type="hidden" id="func">

                                <table width="250" border="0" align="center" cellpadding="5" cellspacing="0">

                                  <tr align="center" valign="top">

                                    <td><a href="javascript:doSubmit()"><img src="${RESOURCE}/eng/images/14_webservice_submit.gif" width="58" height="23" border="0"></a></td>

                                    <td><a href="javascript:gotoWelcome()"><img src="${RESOURCE}/eng/images/14_webservice_cancel.gif" width="58" height="23" border="0"></a></td>

                                  </tr>

                                </table>

                                 

                                <table width="250" border="0" align="center" cellpadding="5" cellspacing="0">

                                  <tr align="center" valign="top">

                                    <td><a href="javascript:HppyCrdtRfllWeb()" ><img src="${RESOURCE}/eng/images/banner_Credit_Refill_via_Refill_Card_en.gif"  border="0"></a></td>

                                  </tr>

                                </table>


                                <!--SVLT.LOOP:success-->

                                <table width="90%"  border="0" cellpadding="2" cellspacing="0" >

                                  <tr>

                                    <td align="center" class="textnormal_bold"  >Your transaction success. Thank you for using this service.</td>

                                  </tr>

                                  <tr>

                                    <td width="489" height="2" align="left" class="textnormal">

                                      <!--SVLT.VAR:total_e-->

                                    </td>

                                  </tr>
								     <tr>

                                    <td width="489" height="2" align="left" class="textnormal">

                                      <!--SVLT.VAR:expire_e--><!--SVLT.VAR:expire_e1-->

                                    </td>

                                  </tr>

                                  <tr>
                                 
                                  <tr>

                                    <td width="489" height="2" align="left" class="textnormal">

                                      <!--SVLT.VAR:bonus_e--></td>

                                  </tr>

                                </table>

                                <p>&nbsp;</p>

                                <!--SVLT.END:success-->

                              </td>

                            </tr>

                            <!--SVLT.VAR:CONF_BOTTOM-->

                          </table>
                        </form>
						
						</td>
                 	</tr>
              	</table>                
                <!--เนื้อหาสิ้นสุดที่นี่-->
                
            </div>
            <div class="content-bottom"></div>
        </div>
    </div>
</div>
<div id="footer">
<img src="${RESOURCE}/eng/images/copy_right.jpg" />
<a href="http://www.dtac.co.th" target="_blank"><img src="${RESOURCE}/eng/images/dtact_logo.jpg" border="0" /></a>
<a href="http://www.happyvirus.com" target="_blank"><img src="${RESOURCE}/eng/images/virus_icon.jpg" border="0" /></a>
</div>
</body>
</html>
